from django.db import models

# Create your models here.

class USER(models.Model):
    user_id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=100)
    gender = models.CharField(max_length=100)
    age = models.IntegerField()
    contact = models.CharField(max_length=100)
    address = models.CharField(max_length=100)
    account = models.CharField(max_length=100)
    password = models.CharField(max_length=100)

    def __str__(self):
        return self.name

class Course(models.Model):
    course_id = models.AutoField(primary_key=True)
    course_name = models.CharField(max_length=100)
    time = models.DateTimeField()
    location = models.CharField(max_length=100)

    
    def __str__(self):
        return self.course_name

class Coach(models.Model):
    coach_id = models.AutoField(primary_key=True)
    coach_name = models.CharField(max_length=100)
    gender = models.CharField(max_length=100)
    specialty = models.CharField(max_length=100)
    contact = models.CharField(max_length=100)
    income = models.IntegerField()
    account = models.CharField(max_length=100)
    password = models.CharField(max_length=100)

    def __str__(self):
        return self.coach_name
    
class Booking(models.Model):
    user = models.ForeignKey(USER,on_delete=models.CASCADE)
    course = models.ForeignKey(Course,on_delete=models.CASCADE)


    def __str__(self):
        return f"{self.user.name,self.course.course_name}"
    
class Teach(models.Model):
    course = models.ForeignKey(Course,on_delete=models.CASCADE)
    coach = models.ForeignKey(Coach,on_delete=models.CASCADE)

    def __str__(self):
        return f"{self.course.course_name,self.coach.coach_name}"